﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Kinect;

namespace KinectStudio.ModuliServomotore
{
    /// <summary>
    /// Interaction logic for Angolatura.xaml
    /// </summary>
    public partial class Angolatura : Window
    {

        KinectSensor sensore=null;

        public Angolatura()
        {
            InitializeComponent();
        }

        
        
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem menuCliccato = (MenuItem)e.OriginalSource;
            switch (menuCliccato.Header.ToString())
            {
                case "Esci":
                    this.Close();
                    break;

            }
        }

        void Imposta_Click(object sender, RoutedEventArgs e)
        {
            if (this.sensore != null)
            {
                this.sensore.ElevationAngle = (int)ui_Angolatura.Value;
            }
            
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.ricavaKinectCollegato();
            this.sensore.Start();
        }

        private void ricavaKinectCollegato()
        {
            foreach (KinectSensor possibileSensore in KinectSensor.KinectSensors)
            {
                if (possibileSensore.Status == KinectStatus.Connected)
                {
                    this.sensore = possibileSensore;
                    break;
                }
            }
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (this.sensore != null)
            {
                this.sensore.Stop();
            }
        }

    }
}
